package com.ruoyi.web.controller.ring;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ring.domain.RingHealthPlan;
import com.ruoyi.ring.service.IRingHealthPlanService;
import com.ruoyi.ring.service.IRingHrvInfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 行动-健康计划
 * 
 * @author liuwp
 * @date 2025-09-01
 */
@RestController
@RequestMapping("/ring/ring_health_plan")
public class RingHealthPlanController extends BaseController
{
    @Resource
    private IRingHealthPlanService ringHealthPlanService;
    @Resource
    private IRingHrvInfoService ringHrvInfoService;

    /**
     * 查询健康计划列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_health_plan:list')")
    @GetMapping("/list")
    public TableDataInfo list(RingHealthPlan ringHealthPlan)
    {
        startPage();
        List<RingHealthPlan> list = ringHealthPlanService.selectRingHealthPlanList(ringHealthPlan);
        return getDataTable(list);
    }

    /**
     * 导出健康计划列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_health_plan:export')")
    @Log(title = "健康计划", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RingHealthPlan ringHealthPlan)
    {
        List<RingHealthPlan> list = ringHealthPlanService.selectRingHealthPlanList(ringHealthPlan);
        ExcelUtil<RingHealthPlan> util = new ExcelUtil<RingHealthPlan>(RingHealthPlan.class);
        util.exportExcel(response, list, "健康计划数据");
    }

    /**
     * 获取健康计划详细信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_health_plan:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ringHealthPlanService.selectRingHealthPlanById(id));
    }

    /**
     * 新增健康计划
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_health_plan:add')")
    @Log(title = "健康计划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RingHealthPlan ringHealthPlan)
    {
        return toAjax(ringHealthPlanService.insertRingHealthPlan(ringHealthPlan));
    }

    /**
     * 修改健康计划
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_health_plan:edit')")
    @Log(title = "健康计划", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RingHealthPlan ringHealthPlan)
    {
        return toAjax(ringHealthPlanService.updateRingHealthPlan(ringHealthPlan));
    }

    /**
     * 删除健康计划
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_health_plan:remove')")
    @Log(title = "健康计划", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ringHealthPlanService.deleteRingHealthPlanByIds(ids));
    }


}
